﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.Core.Prototype;
using YasharEl.Infrastructure.EntityModel;

namespace YasharEl.Infrastructure.Core.EntityModel.Prototype
{
    public abstract class AbstractPropertyMappingEntity : Entity, IPropertyMapping
    {
        #region IPropertyMapping Properties

        public virtual bool IsRequired
        {
            get;
            protected set;
        }

        public virtual bool IsEditable
        {
            get;
            protected set;
        }

        public virtual bool IsVisible
        {
            get;
            protected set;
        }

        public virtual long PropertyMappingId
        {
            get;
            protected set;
        }

        public virtual IPropertyDefinition PropertyDefinition
        {
            get;
            protected set;
        }

        public virtual IHasPropertyDefinitions PropertyDefinitionsContainer
        {
            get;
            protected set;
        }

        #endregion

        #region Abstract Properties

        // TODO: ObjectType abstraction if needed

        #endregion

        #region Objects Overrides

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("Property Mapping Entity: ");

            sb.AppendLine();
            sb.AppendFormat("Mapping id: {0}.", PropertyMappingId);
            sb.AppendLine();
            sb.AppendFormat("Belongs to definition: {0}, id: {1}.", PropertyDefinition.Key, PropertyDefinition.PropertyDefinitionId);
            sb.AppendLine();

            return sb.ToString();
        }

        #endregion

        #region AbstractEntity<long> Overrides

        public override long Id
        {
            get
            {
                return PropertyMappingId;
            }
            protected set
            {
                PropertyMappingId = value;
            }
        }

        #endregion
    }
}
